package cate.game.pvp.guildwar.data.msg;

import cate.common.util.XT;
import cate.game.pvp.guildwar.data.base.GWMatchGroup;
import cate.game.pvp.guildwar.data.base.GuildWarBase;
import cate.game.pvp.guildwar.data.rank.GWGuildRank;
import easy.java.dev.note.NoteField;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GWBaseInnerResp {

	@NoteField("当前赛季")
	public int index;

	@NoteField("赛季开始时间")
	public long startTime;

	@NoteField("赛季结束时间")
	public long endTime;

	@NoteField("对阵列表")
	public List<GWMatchGroup> matchList;

	@NoteField("公会排名")
	public Map<String,Integer> rankMap;

	public static GWBaseInnerResp of(GuildWarBase base, List<GWMatchGroup> matchList, List<GWGuildRank> rankList) {
		GWBaseInnerResp data = new GWBaseInnerResp();
		data.index = base.index;
		data.startTime = base.startTime;
		data.endTime = base.endTime;
		data.matchList = matchList;
		if (XT.isNotBlank(rankList)) {
			data.rankMap = new HashMap<>();
			for (int i = 0; i < rankList.size(); i++) {
				data.rankMap.put(rankList.get(i).profile.uid, i + 1);
			}
		}
		return data;
	}
}
